﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>

    <link href="../../../Content/StyleSheet/Basic.css" rel="stylesheet" type="text/css" />
    <link href="../../../Library/Plugins/MsgBox/StyleSheets/msgBox.css" rel="stylesheet" type="text/css" />
    <link href="../../../Content/LKAssembly/Subject/ViewLibSubject.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .viewMasks
        {
            width: auto;
            height: 400px;
            line-height: 400px;
            display: block;
            left: 0px;
            top: 0px;
            text-align: left;
            padding-left: 250px;
            color: #333;
            float: left;
            margin: -20px 0px 0px 0px;
            background: url(../Common/Images/AllPage/IconQnSaveLoading.gif) no-repeat 230px center;
            position: absolute;
        }
        .viewBox
        {
            overflow-y: auto;
            width: 100%;
            height: 400px;
            float: left;
            display: none;
        }
        .chsBox
        {
            border: solid 1px #f60;
            margin-top: 5px;
            margin-right: 2px;
            background-color: #fafdd8;
        }
        .chsBox .stViewSpace
        {
            background-color: #fafdd8;
        }
        /*2010-05-03 20:00(修改:背景色为#fafdd8)*/</style>

    <script src="/Scripts/JQuery/jquery-1.4.2.js" type="text/javascript"></script>
    <script src="/Scripts/Base/LKConfig.js" type="text/javascript"></script>
    <script src="/Scripts/Base/Global.js" type="text/javascript"></script>
    <script src="../../../Library/Plugins/MsgBox/JavaScripts/jQuery.msgBox.js" type="text/javascript"></script>
    <script src="../../../Scripts/Views/LKAssembly/Subject/ViewLibSubject.js" type="text/javascript"></script>
    <script type="text/javascript" language="javascript">

        $(function() {
            PageManage.ready();
        });

        var PageManage = {

            ready: function() {
                this.initBox();
                this.getUrlArg();
            },

            viewBox: 0, maskBox: 0,

            initBox: function() {
                this.viewBox = this.viewBox || $("#ViewBox");
                this.maskBox = this.maskBox || $("#ViewMasks");
            },

            setDisplayMask: function(type) {
                this.maskBox[type == "show" ? "show" : "hide"]();
            },

            getUrlArg: function() {
                var _href = window.location.href,
                    _indGuid = _href.indexOf("guid="),
                    _state = _href.indexOf("state=");

                //修改guidTeam
                if (_indGuid != -1) {
                    var _guidTeam = _href.substring(_indGuid + 5, _href.length).split("&")[0];
                    if (_state != -1) {
                        _state = _href.substring(_state + 6, _href.length).split("&")[0];
                        switch (_state) {
                            case "0":
                            case "1":
                            case "2":
                            case "3":
                                _state = parseInt(_state);
                                break;
                            default:
                                _state = null;
                                break;
                        }
                    }
                    else {
                        _state = 2;
                    }
                    _guidTeam.length == 36 && AjaxGetData.get单题预览(_guidTeam, _state);
                }
            }
        };

        var 预览单题管理 = {

            setViewByHtml: function(html, contID) {

                //设置需显示的HMTL
                PageManage.viewBox.fadeIn("normal", function() {
                    PageManage.setDisplayMask("hide");
                    PageManage.viewBox.html(html);
                    PageManage.viewBox[0].style.display = 'block';
                    //如有子小题则定位滚动条位置
                    if (contID) {
                        var _nameElem = $("<a id=\"" + contID + "Link\" href=\"#" + contID + "\" name=\"#" + contID + "\"><\/a>");

                        $("#" + contID).addClass("chsBox").before(_nameElem).fadeIn(function() {
                            try {
                                document.getElementById(contID + "Link").click();
                            }
                            catch (e) {
                            }
                            var _top = PageManage.viewBox.scrollTop();
                            PageManage.viewBox.scrollTop(_top - 30);
                        });
                    }
                });
            },

            clearView: function() {
                PageManage.setDisplayMask("show");
                PageManage.viewBox.html("").hide();
            },

            setViewByJson: function(json, contID, state) {
                this.clearView();
                state = state != null ? state : 2;
                ViewLibSubject.getItemHtml(state, json, null, function(html) {
                    预览单题管理.setViewByHtml(html, contID);
                }, null, true, false, false, false);
            }
        };

        var AjaxGetData = {
            get单题预览: function (guidTeam, state) {
                $.ajax({
                    type: "POST",
                    url: "/LKSubject/WithoutAnAndRe/" + guidTeam,
                    data: {
                        action: "试题不带答案与解析",
                        guid: guidTeam
                    },
                    dataType: "json",

                    //提交服务器成功
                    success: function (data) {
                        if (data.result) {
                            if (typeof data.info == "string") {
                                data.info = eval("(" + data.info + ")");
                            }
                            预览单题管理.setViewByJson(data.info, null, state)
                        }
                        //执行失败的程序
                        else {

                        }
                    },
                    //提交服务器错误
                    error: function (xml, text, thrown) {

                    }
                });
            }
        }
        
    </script>

</head>
<body>
    <div class="viewMasks" id="ViewMasks">
        数据正在加载中......
    </div>
    <div class="viewBox" id="ViewBox">
    </div>
</body>
</html>
